<template>
  <div class="dashboard-container">
    <div class="dashboard-text">
      <h1>欢迎使用精进坊管理系统</h1>
      <p>这是一个基于Vue3 + Element Plus的后台管理系统</p>
    </div>
    
    <!-- 统计卡片 -->
    <el-row :gutter="20" class="stats-row">
      <el-col :span="6">
        <el-card class="stats-card">
          <div class="stats-content">
            <div class="stats-icon user-icon">
              <el-icon size="40"><User /></el-icon>
            </div>
            <div class="stats-info">
              <div class="stats-number">{{ stats.userCount }}</div>
              <div class="stats-label">用户总数</div>
            </div>
          </div>
        </el-card>
      </el-col>

      <el-col :span="6">
        <el-card class="stats-card">
          <div class="stats-content">
            <div class="stats-icon content-icon">
              <el-icon size="40"><Document /></el-icon>
            </div>
            <div class="stats-info">
              <div class="stats-number">{{ stats.contentCount }}</div>
              <div class="stats-label">内容总数</div>
            </div>
          </div>
        </el-card>
      </el-col>

      <el-col :span="6">
        <el-card class="stats-card">
          <div class="stats-content">
            <div class="stats-icon comment-icon">
              <el-icon size="40"><ChatDotRound /></el-icon>
            </div>
            <div class="stats-info">
              <div class="stats-number">{{ stats.commentCount }}</div>
              <div class="stats-label">评论总数</div>
            </div>
          </div>
        </el-card>
      </el-col>

      <el-col :span="6">
        <el-card class="stats-card">
          <div class="stats-content">
            <div class="stats-icon member-icon">
              <el-icon size="40"><Star /></el-icon>
            </div>
            <div class="stats-info">
              <div class="stats-number">{{ stats.memberCount }}</div>
              <div class="stats-label">会员总数</div>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
    
    <!-- 快捷操作 -->
    <el-row :gutter="20" class="quick-actions">
      <el-col :span="12">
        <el-card>
          <template #header>
            <span>快捷操作</span>
          </template>
          <div class="action-buttons">
            <el-button type="primary" @click="$router.push('/content/add')">
              <el-icon><Plus /></el-icon>
              添加内容
            </el-button>
            <el-button type="success" @click="$router.push('/user/list')">
              <el-icon><User /></el-icon>
              用户管理
            </el-button>
            <el-button type="warning" @click="$router.push('/comment/list')">
              <el-icon><ChatDotRound /></el-icon>
              评论管理
            </el-button>
            <el-button type="info" @click="$router.push('/system/config')">
              <el-icon><Setting /></el-icon>
              系统设置
            </el-button>
          </div>
        </el-card>
      </el-col>

      <el-col :span="12">
        <el-card>
          <template #header>
            <span>系统信息</span>
          </template>
          <div class="system-info">
            <div class="info-item">
              <span class="info-label">系统版本：</span>
              <span class="info-value">v1.0.0</span>
            </div>
            <div class="info-item">
              <span class="info-label">Vue版本：</span>
              <span class="info-value">3.3.4</span>
            </div>
            <div class="info-item">
              <span class="info-label">Element Plus：</span>
              <span class="info-value">2.4.1</span>
            </div>
            <div class="info-item">
              <span class="info-label">运行环境：</span>
              <span class="info-value">开发环境</span>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'

const stats = ref({
  userCount: 0,
  contentCount: 0,
  commentCount: 0,
  memberCount: 0
})

onMounted(() => {
  // 模拟加载统计数据
  setTimeout(() => {
    stats.value = {
      userCount: 1234,
      contentCount: 567,
      commentCount: 890,
      memberCount: 123
    }
  }, 500)
})
</script>

<style scoped>
.dashboard-container {
  padding: 20px;
  width: 100%;
  min-width: 900px;
  margin: 0 auto;
}

.dashboard-text {
  text-align: center;
  margin-bottom: 40px;
}

.dashboard-text h1 {
  color: #303133;
  margin-bottom: 10px;
}

.dashboard-text p {
  color: #606266;
  font-size: 16px;
}

.stats-row {
  margin-bottom: 40px;
}

.stats-card {
  cursor: pointer;
  transition: all 0.3s;
}

.stats-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.stats-content {
  display: flex;
  align-items: center;
  padding: 10px 0;
}

.stats-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 20px;
}

.user-icon {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.content-icon {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.comment-icon {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
}

.member-icon {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  color: white;
}

.stats-info {
  flex: 1;
}

.stats-number {
  font-size: 28px;
  font-weight: bold;
  color: #303133;
  margin-bottom: 5px;
}

.stats-label {
  color: #909399;
  font-size: 14px;
}

.quick-actions {
  margin-bottom: 40px;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-buttons .el-button {
  margin: 0;
}

.system-info {
  padding: 10px 0;
}

.info-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.info-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.info-label {
  color: #606266;
  font-weight: 500;
}

.info-value {
  color: #303133;
}
</style>